﻿<html xmlns:th="http://www.thymeleaf.org">
<head>
    <!--资源获取-->
    <base th:href="|${#request.getContextPath()}/|">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="static/lib/html5shiv.js"></script>
    <script type="text/javascript" src="static/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="static/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="static/lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <!--layui-->
    <link rel="stylesheet" type="text/css" href="static/layui/css/layui.css"/>
    <script type="text/javascript" src="static/layui/layui.js"></script>
    <title>资讯列表</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i>
    首页
    <span class="c-gray en">&gt;</span>
    模拟投资
    <span class="c-gray en">&gt;</span>
    投资收藏
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
       href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    <!--收藏-->
    <a id="djsc" class="btn btn-success radius r " style="line-height:1.6em;margin-top:3px" href="javascript:;"
       title="收藏">
        <i id="sc" class=" Hui-iconfont">&#xe69d;</i>
        <i id="qxsc" class=" Hui-iconfont">&#xe69e;</i></a>
    <!--收藏-->
</nav>
<div class="page-container">
    <div>
        <fieldset class="layui-elem-field">
            <legend>搜索</legend>
            <div class="layui-field-box">
                <form>
                    <div class="layui-inline">
                        <label class="layui-form-label">代码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="daima" >
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">类别：</label>
                        <div class="layui-inline">
                            <select id="lb" name="city" lay-verify="">
                                <option value="">请选择一个类别</option>
                                <option value="1">股票</option>
                                <option value="2">基金</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline" style="float: right;">
                        <div class="layui-inline">
                            <button id="selectMyIn" class="layui-btn" data-type="reload">搜索</button>
                        </div>
                    </div>
                </form>
            </div>

        </fieldset>

    </div>
    <table class="layui-hide" id="sctz" lay-filter="sctz"></table>

    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
            <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
        </div>
    </script>

    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="edit">详细</a>
    </script>


    <script type="text/javascript" src="static/lib/jquery/1.9.1/jquery.min.js"></script>

    <script type="text/javascript" src="static/lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="static/lib/laypage/1.2/laypage.js"></script>
    <script>
        /*时间选择*/
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            //常规用法
            laydate.render({
                elem: '#startTime'
            });
            laydate.render({
                elem: '#endTime'
            });
        });
        /*收藏按钮*/
        var ejhref = "Investment/CollectionTz";//收藏路径
        var ejhrefname = "投资收藏"
        $.ajax({
            url: "CollectionPage?page=" + ejhref,
            async: false,
            type: "GET",
            success: function (datas) {
                if (datas == "sc") {

                    $("#qxsc").addClass("layui-hide");
                    $("#sc").addClass("layui-show");

                } else {
                    $("#sc").addClass("layui-hide");
                    $("#qxsc").addClass("layui-show");
                }
            }
        })
        $("#djsc").on("click", function () {

            $.ajax({
                url: "CollectionNewPage",
                type: "POST",
                data: {
                    "page": ejhref,
                    "pageName": ejhrefname//收藏名字
                },
                success: function (regas) {
                    if (regas != "sc") {

                        $("#qxsc").attr("class", "Hui-iconfont layui-hide");
                        $("#sc").attr("class", "Hui-iconfont layui-show");

                    } else {
                        $("#sc").attr("class", "Hui-iconfont layui-hide");
                        $("#qxsc").attr("class", "Hui-iconfont layui-show");
                    }

                }
            })

        })
        /*收藏按钮*/


        /*时间转换*/
        function GetNumberOfDays(date1, date2) {//获得天数
            //date1：开始日期，date2结束日期
            var a1 = Date.parse(new Date(date1));
            var a2 = Date.parse(new Date(date2));
            var day = parseInt((a2 - date1) / (1000 * 60 * 60 * 24));//核心：时间戳相减，然后除以天数
            return day
        };
        /*表格*/
        layui.use('table', function () {
            var table = layui.table;
            var tableIns = table.render({
                elem: '#sctz'
                , url: '/Investment/SelectCollection'
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['filter', 'exports', 'print',]
                , title: '投资收藏'
                , cols: [
                    [
                        {type: 'checkbox', fixed: 'left'}
                        ,{field:'code', title:'代码', fixed: 'left', unresize: true, sort: true}
                        ,{field:'name', title:'名字', fixed: 'left', unresize: true, sort: true}
                        ,{field:'lb', title:'类别' ,sort: true}
                        , {field: 'jr', title: '今日价格', sort: true}
                        , {field: 'zf', title: '今日涨幅', sort: true}
                        , {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 100}
                    ]
                ]
                , page: true
            });

            /*表格重载*/
            $('#selectMyIn').on('click', function () {
                var daima =$('#daima').val();
                var lb =  $('#lb').val();
                tableIns.reload({
                    url: '/Investment/SelectCollection',
                    page: {curr: 1},
                    where: {
                        "daima": daima,
                        "lb": lb
                    }
                })
            })


            //头工具栏事件
            table.on('toolbar(zxtz)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                switch (obj.event) {
                    case 'getCheckData':
                        var data = checkStatus.data;
                        layer.alert(JSON.stringify(data));
                        break;
                    case 'getCheckLength':
                        var data = checkStatus.data;
                        layer.msg('选中了：' + data.length + ' 个');
                        break;
                    case 'isAll':
                        layer.msg(checkStatus.isAll ? '全选' : '未全选');
                        break;
                }
                ;
            });

            //监听行工具事件
            table.on('tool(sctz)', function (obj) {
                var data = obj.data;
                console.log(obj);
                if (obj.event === 'edit') {
                    var lbb ;
                    if(data.lb=="股票"){
                        lbb=1;
                    }else {
                        lbb = 2;
                    }
                    //创新的页面
                    creatIframe("Investment/GoJdInvestment?code="+data.code+"&lb="+lbb,"常规投资")
                }
            });
        });
    </script>

    <script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="static/lib/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
    <script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript" src="static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
    <script type="text/javascript" src="static/lib/datatables/1.10.15/jquery.dataTables.min.js"></script>
    <script type="text/javascript">


    </script>
</div>
</body>
</html>
